<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <script type="text/javascript">
    console.log("========== return 函数的调用 ===========");
    function add(x,y){
      return x+y;
      console.log("返回后面的代码");
    }

    console.log(add(2,3));

    console.log("========== 递归 ===========");
    function fib(num){
      if (num >2) {
        return fib(num - 2) + fib(num - 1);
      }else{
        return 1;
      }
      }
    console.log(fib(6));

    console.log("==========使用值的地方，就能使用函数================");
    var option = add;
    console.log(option(5,6));

    function a(op) {
      return op;
    }
    a(add(8.9));

    console.log (a(add(8,9)));

    var b={
      name :add,
    }
    console.log(b.name(5,6));

    console.log("========== name 的属性 ============");
    console.log("==========属性返回紧跟在function 关键字之后的属性名 ========");
    console.log("======== f1 ===============");
    function f1(){

    }
    console.log(f1.name);

    var f2 = function () {

    }
    console.log("======== f2 ======");
    console.log(f2.name);

    console.log("=========length属性 ========");
    console.log("=========length属性返回函数预期传入的参数个数，即函数定义之中的参数个数 ========");
    function f3(a,b,c,d){

    }

    console.log("=====函数的toString方法返回函数的源码 ========");
    function f4(){
      a();
      b();
      c();
      d();
      }
      console.log("======== 利用这一点，可以变相实现多行字符串======");
      var f5 = function (fn){
        var arr = fn.toString().split("\n");
        return arr.slice(1,arr.length-1).join();
      }
      function f6(){


      }

      console.log(f5(f6.toString()));

      console.log("=======全局变量；在函数外 =======");
      var name = "depang";

      function f7(){
        return name;
      }
      function f8(){
        return name + " is good";
      }

      console.log(f7());
      console.log(f8());
      console.log(f7()+f8());
    </script>
  </body>
</html>
